out_file_name = "out.cpp"
in_file_name = "solve.cpp"

out_file = open(out_file_name, "w", encoding='utf-8')
in_file = open(in_file_name, "r", encoding='utf-8')

print('读取solve.cpp')
while True:
    line = in_file.readline()
    if line == '// ------------START-------------------\n':
        break

print('写入solve函数到', in_file_name)
out_file.write(in_file.read())

print('生成main函数到', in_file_name)
out_file.writelines([
    '\n\n',
    'signed main() {\n',
    '   ios::sync_with_stdio(false);\n',
    '   cin.tie(nullptr), cout.tie(nullptr);\n',
    '   solve();\n',
    '   return 0;\n',
    '}\n'
])

in_file.close()
out_file.close()

print('完成')
